home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / wtj009.zip / CPP_DLL.ZIP / LISTINGS.TXT < prev    next >
Text File  |  1992-08-14  |  4KB  |  167 lines

  1.  
  2.  
  3. ============================================================================
  4. [LISTING 1 - HELLO.CPP]
  5.  
  6. // hello.cpp RHS 7/15/92
  7.  
  8. #include<windows.h>
  9.  
  10. LPSTR wintitle = "HELLO";
  11. LPSTR winmessage ="Hello, world!";
  12.  
  13. void FAR PASCAL HelloMessage(LPCSTR wintitle)
  14.     {
  15.     MessageBox(NULL,winmessage,wintitle,MB_OK);
  16.     }
  17.  
  18. int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  19.     {
  20.     HelloMessage(wintitle);
  21.     return 0;
  22.     }
  23.  
  24. ============================================================================
  25. [LISTING 2 - HELLO2.CPP]
  26.  
  27. // hello2.cpp RHS 7/15/92
  28.  
  29. #include<windows.h>
  30. #include"hello.h"
  31.  
  32. LPSTR wintitle = "HELLO2";
  33.  
  34. int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  35.     {
  36.     HelloMessage(wintitle);
  37.     return 0;
  38.     }
  39.  
  40.  
  41. ============================================================================
  42. [LISTING 3 - HELLOLIB.CPP]
  43.  
  44. // hellolib.cpp RHS 7/15/92
  45.  
  46. #include<windows.h>
  47. #include"hello.h"
  48.  
  49. #if defined(_MSC_VER)
  50. extern "C" int FAR PASCAL LibMain(HINSTANCE,WORD,WORD,LPSTR)
  51.     {
  52.     return TRUE;
  53.     }
  54.  
  55. extern "C" int FAR PASCAL _WEP(int)
  56.     {
  57.     return TRUE;
  58.     }
  59. #else
  60. int FAR PASCAL LibMain(HINSTANCE,WORD,WORD,LPSTR)
  61.     {
  62.     return TRUE;
  63.     }
  64.  
  65. int FAR PASCAL WEP(int)
  66.     {
  67.     return TRUE;
  68.     }
  69. #endif
  70.  
  71. LPSTR winmessage = "Hello, world!";
  72.  
  73. void FAR PASCAL _export HelloMessage(LPSTR wintitle)
  74.     {
  75.     MessageBox(NULL,winmessage,wintitle,MB_OK);
  76.     }
  77.  
  78.  
  79. ============================================================================
  80. [LISTING 4 - MAKE FILES]
  81.  
  82. #Borland C++ Make file:
  83.  
  84. all: hello.exe hellolib.dll hellolib.lib hello2.exe
  85.  
  86.  
  87. hello.exe: hello.cpp 
  88.     bcc -WS -DSTRICT hello.cpp
  89.  
  90. hellolib.dll: hellolib.def hellolib.cpp hello.h
  91.     bcc -WD -DSTRICT hellolib.cpp
  92.  
  93. hellolib.lib: hellolib.dll
  94.     implib hellolib.lib hellolib.dll
  95.  
  96. hello2.exe: hello2.cpp hellolib.lib hello.h
  97.     bcc -WS -DSTRICT hello2.cpp hellolib.lib
  98.    
  99.  
  100.  
  101. #Microsoft C++ 7.0 Make file:
  102.  
  103. all: hello.exe hellolib.dll hellolib.lib hello2.exe
  104.  
  105.  
  106. hello.exe: hello.cpp 
  107.  
  108.     cl /GA /DSTRICT hello.cpp hello.def
  109.  
  110. hellolib.dll: hellolib.def hellolib.cpp hello.h
  111.     cl /c /GD /DSTRICT hellolib.cpp
  112.     link hellolib,hellolib.dll,null,libw sdllcew,hellolib.def;
  113.  
  114. hellolib.lib: hellolib.dll
  115.     implib hellolib.lib hellolib.dll
  116.  
  117. hello2.exe: hello2.cpp hellolib.lib hello.h
  118.     cl /c /GA /DSTRICT hello2.cpp
  119.     link hello2,hello2.exe,null,libw slibcew hellolib,hello2.def;
  120.  
  121.  
  122. ============================================================================
  123. [LISTING 5 - MODULE DEFINITION (.DEF) FILES]
  124.  
  125. ; HELLO.DEF
  126. NAME            HELLO
  127. DESCRIPTION     'Hello'
  128. STUB            'winstub.exe'
  129. EXETYPE         WINDOWS
  130. HEAPSIZE        8192
  131. STACKSIZE       8192
  132.  
  133.  
  134. ; HELLOLIB.DEF
  135. LIBRARY         HELLOLIB
  136. DESCRIPTION     'Hello Library'
  137. STUB            'winstub.exe'
  138. EXETYPE         WINDOWS
  139. CODE            MOVEABLE PRELOAD
  140. DATA            SINGLE MOVEABLE PRELOAD
  141. HEAPSIZE        8192
  142.  
  143.  
  144. ; HELLO2.DEF
  145. NAME            HELLO2
  146. DESCRIPTION     'Hello2'
  147. STUB            'winstub.exe'
  148. EXETYPE         WINDOWS
  149. HEAPSIZE        8192
  150. STACKSIZE       8192
  151.  
  152. ============================================================================
  153. [LISTING 6 - HELLO.H]
  154.  
  155. // hello.h RHS 7/15/92
  156.  
  157. #if defined(_WINDLL) || (__DLL__)
  158. #define EXPORT _export
  159. #else
  160.  
  161. #define EXPORT
  162. #endif
  163.  
  164. extern void FAR PASCAL EXPORT HelloMessage(LPSTR wintitle);
  165.  
  166. =====================================================================
  167.